/**
 * problem_009.c
 * Copyright (C) 2011-03-18 - xrose
 * There exists exactly one Pythagorean triplet for which a + b + c = 1000.
 * Find the product abc.
 */
#include <stdio.h>
#include <math.h>
#define square(x) (x)*(x)
int main (int argc, char *argv[])
{
    int a, b;
    for(a=1; a<1000; a++)
    {
        for(b=a; b<1000-(2*a); b++)
        {
            if(square(a)+square(b)==square(1000-(a+b)))
            {
                printf("The answer is: %d\n", a*b*(1000-a-b));
                return 0;
            }
        }
    }
    return 0;
}

